import type { VbenFormSchema } from '#/adapter/form';

import { $t } from '#/locales';

export const schema: VbenFormSchema[] = [
  {
    component: 'RadioGroup',
    fieldName: 'enabled',
    label: $t('views.crm.config.pool.enabled'),
    componentProps: {
      options: [
        { label: $t('views.common.enable'), value: true },
        { label: $t('views.common.disable'), value: false },
      ],
    },
  },
  {
    component: 'InputNumber',
    fieldName: 'contactExpireDays',
    componentProps: {
      min: 0,
      precision: 0,
    },
    renderComponentContent: () => ({
      addonAfter: () => $t('views.crm.config.pool.contactExpireDaysAfter'),
    }),
    dependencies: {
      triggerFields: ['enabled'],
      show: (value) => value.enabled,
    },
  },
  {
    component: 'InputNumber',
    fieldName: 'dealExpireDays',
    renderComponentContent: () => ({
      addonBefore: () => $t('views.crm.config.pool.dealExpireDaysBefore'),
      addonAfter: () => $t('views.crm.config.pool.dealExpireDaysAfter'),
    }),
    componentProps: {
      min: 0,
      precision: 0,
    },
    dependencies: {
      triggerFields: ['enabled'],
      show: (value) => value.enabled,
    },
  },
  {
    component: 'RadioGroup',
    fieldName: 'notifyEnabled',
    label: $t('views.crm.config.pool.notifyEnabled'),
    componentProps: {
      options: [
        { label: $t('views.common.enable'), value: true },
        { label: $t('views.common.disable'), value: false },
      ],
    },
    dependencies: {
      triggerFields: ['enabled'],
      show: (value) => value.enabled,
    },
    defaultValue: false,
  },
  {
    component: 'InputNumber',
    fieldName: 'notifyDays',
    componentProps: {
      min: 0,
      precision: 0,
    },
    renderComponentContent: () => ({
      addonBefore: () => $t('views.crm.config.pool.notifyDaysBefore'),
      addonAfter: () => $t('views.crm.config.pool.notifyDaysAfter'),
    }),
    dependencies: {
      triggerFields: ['notifyEnabled', 'enabled'],
      show: (value) => value.enabled && value.notifyEnabled,
    },
  },
];
